<template>
    <div style="min-width:809px">
       <div v-if="$route.path == '/personalAdmin/personalChanges'">
            <div class="vs-search-box" style="padding: 24px 22px 0 0px;">
                
                <el-form ref="form" :inline="true" :model="paging" label-width="90px">
                    <el-form-item label="门店">
                        <el-select v-model="paging.store_id" style="width:230px" placeholder="请选择">
                            <el-option
                                v-for="item in shopList"
                                :key="item.id"
                                :label="item.title"
                                :value="item.id">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="类型">
                        <el-select v-model="paging.type" style="width:230px" placeholder="请选择">
                            <el-option label="调动" :value="1"> </el-option>
                            <el-option label="离职" :value="2"> </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="" class="fl-right">
                        <el-button @click="reset">重置</el-button>
                        <el-button @click="init()"  type="primary">查询</el-button>
                    </el-form-item>
                    <el-form-item label="员工">
                        <el-input style="width:230px" v-model="paging.name"></el-input>
                    </el-form-item>
                    <el-form-item label="账户状态">
                        <el-select v-model="paging.account_status" style="width:230px" placeholder="请选择">
                            <el-option label="正常" :value="1"> </el-option>
                            <el-option label="停用" :value="0"> </el-option>
                        </el-select>
                    </el-form-item>
                </el-form>
            </div>
            <div class="vs-table-box">
                <div class="operation-box">
                    <el-button class="left-auto" @click="derive" :loading="isDerive" icon="el-icon-download" size="medium" >导出</el-button>
                </div>
                <el-table 
               
                :header-cell-style="{background:'#f5f6f8'}" v-loading="loading" :data="tableData" header-row-class-name="has-gutter-table" style="width: 100%">
                    <el-table-column width="60px" type="selection" ></el-table-column>
                    <el-table-column width="60px" label="序号" prop="num" ></el-table-column>
                    <el-table-column prop="store.title" label="门店" > </el-table-column>
                    <el-table-column prop="name" label="员工姓名"> </el-table-column>
                    <el-table-column prop="number" label="员工工号"> </el-table-column>
                    <el-table-column prop="position.title" label="职位">
                        
                    </el-table-column>
                    <el-table-column prop="into_time" min-width="140" label="入职时间">
                        <template slot-scope="scope">
                            {{scope.row.into_time | parseTime('{y}-{m}-{d} {h}:{i}')}}
                        </template>
                    </el-table-column>
                    <el-table-column prop="transfer_time" min-width="140" label="异动时间">
                        <template slot-scope="scope">
                            {{scope.row.transfer_time | parseTime('{y}-{m}-{d} {h}:{i}')}}
                        </template>
                    </el-table-column>
                    <el-table-column prop="content" width="130" label="异动原因"> 
                        <template slot-scope="scope">
                            <span class="line-2" :title="scope.row.content">{{scope.row.content}}</span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="type" label="类型">
                        <template slot-scope="scope">
                            {{scope.row.type | moveType}}
                        </template>
                    </el-table-column>
                    <el-table-column prop="account_status" label="账户状态">
                        <template slot-scope="scope">
                            {{scope.row.account_status | userType}}
                        </template>
                    </el-table-column>
                </el-table>
                <div class="vs-paging-box">
                    <el-pagination
                        @current-change="handleCurrentChange"
                        :current-page.sync="paging.page"
                        :page-size="paging.limit"
                        layout="prev, pager, next, jumper"
                        :total="paging.total">
                    </el-pagination>
                </div>
            </div>
       </div>
       <router-view></router-view>
    </div>
</template>

<script>
export default {
    data() {
        return {
            paging:{
                name:'',
                store_id:'',
                account_status:'',//1 -1
                type:'',//类型：1调动，2离职
                page:1,
                total:0,
                limit:10,
            },
            loading:false,
            shopList:[],
            isDerive:false,
            tableData: [
            ]
        };
    },
    filters:{
        typeName(val){
            switch (val) {
                case 1:
                    val = '内部'
                    break;
                case 2:
                    val = '外部'
                    break;
            }
            return val;
        }
    },
    created() {
        this.homegetStore();
        this.getList();
    },
    methods: {
        async derive(){
            this.isDerive = true;
            let res = await this.$Http.getTransferExport(this.paging);
            this.utils.downloadXlsx(res,'员工异动')
            this.isDerive = false;
        },
        reset(type){
            if(type){
                this.paging = this.$options.data().paging;
            }
            this.paging.page = 1;
            this.getList();
        },
        init(){
            this.paging.page = 1;
            this.getList();
        },
        async homegetStore(){
            let {code,data} = await this.$Http.homegetStore();
            if(code){
                this.shopList = data;
            }
        },
        handleCurrentChange(val){
            this.paging.page = val;
            this.getList()
        },
        async getList(){
            this.loading = true;
            let {code,data} = await this.$Http.staffgetTransfer(this.paging);
            this.loading = false;
            if(code){
                this.tableData = data.data;
                this.paging.total = data.total;
            }
        },
        pickerDate(){

        },
        change(){

        }
    },
};
</script>

<style lang="scss" scoped>

.image-thumbnail{
    width: 130px;
    height: 130px;
}
</style>